from appium import webdriver

def init_driver():
    # server 启动参数
    desired_caps = {}
    # 设备信息
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '5.1.1'
    desired_caps['deviceName'] = '127.0.0.1:62001'
    # 指定要操作某app的某UI
    desired_caps['appPackage'] = 'com.android.contacts'
    desired_caps['appActivity'] = '.activities.PeopleActivity'  # 主UI
    desired_caps['noReset']=True

    # 指定Appium服务器的ip和端口
    return  webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)